package cn.terminus.data.customer.contractselldefypaymentoverdueinfo.impl;

import cn.terminus.common.customer.bean.contractselldefypaymentoverdueinfo.dto.*;
import cn.terminus.data.customer.contractselldefypaymentoverdueinfo.dao.ContractSellDefyPaymentOverdueInfoDao;
import cn.terminus.data.customer.contractselldefypaymentoverdueinfo.mapper.ContractSellDefyPaymentOverdueInfoMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * 合同付款违约(ContractSellDefyPaymentOverdueInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-07-21 11:18:47
 */
@Repository
public class ContractSellDefyPaymentOverdueInfoDaoImpl implements ContractSellDefyPaymentOverdueInfoDao {
    @Resource
    private ContractSellDefyPaymentOverdueInfoMapper contractSellDefyPaymentOverdueInfoMapper;

    @Override
    public Integer add(ContractSellDefyPaymentOverdueInfoNewDto dto) {
        return contractSellDefyPaymentOverdueInfoMapper.add(dto);
    }

    @Override
    public Integer update(ContractSellDefyPaymentOverdueInfoEditDto dto) {
        return contractSellDefyPaymentOverdueInfoMapper.update(dto);
    }

    @Override
    public List<ContractSellDefyPaymentOverdueInfoResultDto> gets(ContractSellDefyPaymentOverdueInfoGetsDto dto) {
        return contractSellDefyPaymentOverdueInfoMapper.gets(dto);
    }

    @Override
    public List<ContractSellDefyPaymentOverdueInfoResultDto> query(ContractSellDefyPaymentOverdueInfoQueryDto dto) {
        return contractSellDefyPaymentOverdueInfoMapper.query(dto);
    }

    @Override
    public Integer delete(ContractSellDefyPaymentOverdueInfoDeleteDto dto) {
        return contractSellDefyPaymentOverdueInfoMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<ContractSellDefyPaymentOverdueInfoResultDto> page(ContractSellDefyPaymentOverdueInfoQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<ContractSellDefyPaymentOverdueInfoResultDto> result = (Page<ContractSellDefyPaymentOverdueInfoResultDto>) contractSellDefyPaymentOverdueInfoMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), ContractSellDefyPaymentOverdueInfoResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer deleteWithContractId(Long id) {
        return contractSellDefyPaymentOverdueInfoMapper.deleteWithContractId(id);
    }
}
